package com.nut.spp.redis;

import com.nut.spp.enums.IdTagEnum;
import com.nut.spp.enums.SmsEnum;
import com.nut.spp.util.DateUtil;

public class RedisKeys {

    public final static String SMS = "sms:";
    public final static String SPLIT = ":";
    public final static String IMG_CODE = "img_code:";
    public final static String ORDER_LOCK = "order:";
    public final static String CART_ADD = "cart_add:";

    //每日验证码短信数量
    public final static String SMS_VERIFY_COUNT = "sms_verify_count:";
    public final static String SMS_COUNT = "smscnt:";
    public final static String GOODS_QUANTITY = "goods_quantity:";

    public static final String getGoodsQuantity(Integer goodsId, String spec) {
        return GOODS_QUANTITY + goodsId.toString() + ":" + spec;
    }

    public static final String getImgCodeKey(String uuid) {
        return IMG_CODE + uuid;
    }

    public static final String getSmsMobileKey(String mobile) {
        return SMS + mobile;
    }

    public static final String getOrderKey(String orderId) {
        return ORDER_LOCK + orderId;
    }

    public static final String getCartAdd(String memberId) {
        return CART_ADD + memberId;
    }

    public static final String getPrefixKey(IdTagEnum idTagEnum) {
        String date = DateUtil.getYYMMdd(0);
        String prefix = date + idTagEnum.getValue();
        return prefix;
    }

    public static final String getSmsCodeKey(String mobile, SmsEnum smsEnum) {
        return SMS + smsEnum.toString() + SPLIT + mobile;
    }

    /**
     * 每日验证码短信数量的key
     */
    public static final String getSmsVerifyCountKey(String mobile) {
        return SMS_VERIFY_COUNT + DateUtil.getNowDate() + SPLIT + mobile;
    }

    public static final String getSmsCountMobileKey(String mobile) {
        return SMS_COUNT + DateUtil.getNowDate() + SPLIT + mobile;
    }

    public static void main(String[] args) {

    }
}
